$(function(){
	window.onload = function(){
		$("#bottom").hide();
		var url = "/BookStoreManager/getRightNews";
		var param = {"time":new Date()};
		$.post(url,param,function(data){
			var smallNews = document.getElementById("smallNews");
			for(var i = 0;i<data.length;i++){
                var node = document.createElement("a");
                node.innerHTML = data[i].title;
                node.href="/BookStoreManager/enterRightNews?title="+data[i].title+"&date="+data[i].date;
                var tempclass = ".newNode"+i;
                node.setAttribute("class", "newNode"+i);
                smallNews.appendChild(node);
                var brNode = document.createElement("br");
                smallNews.appendChild(brNode);
               
			}
			$("#bottom").fadeIn("slow");
       });
		//超级管理员登录教工信息管理
		$(".adminManager").click(function(){
			$.ajax({
				type:"POST",
				url:"/ManagerSystem/manager/goMessageManager",
				success:function(data){
					if(data.result=="当前身份错误"){
						alert("当前登录用户没有权限进入");
					}
					else if (data.result=="当前身份正确"){
						window.location.href = "/ManagerSystem/views/admin.jsp";
					}
					else if(data.result=="请先登录"){
						alert("请先登录");
					}
					else{
						alert("Unknow Erro");
					}
				}
			})
			return false;
		})
		
		
	
		    //主页登陆学生服务子系统
		 $(".studentMessageLogin").click(function(){
			 var url = "/ManagerSystem/manager/studentMessageLogin";
			 $.get(url,function(data){
				 var result = data.result;
				 if(result=="有权限访问"){
					 window.location.href = "/ManagerSystem/manager/goStudentMessage";
				 }
				 else if(result=="没有权限访问")
					 alert("当前用户不是学生");
				 else{
					 alert("请先登陆");
				 }
			 });
			 return false;
		 });
		$(".teacherFileManager").click(function(){
			$.ajax({
				type:"GET",
				url:"/ManagerSystem/manager/goFileManager",
				success: function(data){
					if(data.result=="请先登录"){
						alert("请先登录");
					}
					else if(data.result=="当前用户是老师"){
						window.location.href = "/ManagerSystem/manager/enterFileManager"
					}
					else if(data.result="当前用户是学生"){
						alert("当前用户不是老师");
					}
					else{
						alert("Unknow erro");
					}
				}	
			})
			return false;
		})
		$(".studentFileManager").click(function(){
			$.ajax({
				type:"GET",
				url:"/ManagerSystem/manager/goFileManager",
				success: function(data){
					if(data.result=="请先登录"){
						alert("请先登录");
					}
					else if(data.result=="当前用户是学生"){
						window.location.href = "/ManagerSystem/views/FileStudent.jsp"
					}
					else if(data.result="当前用户是老师"){
						alert("当前用户不是老师");
					}
					else{
						alert("Unknow erro");
					}
				}	
			})
			return false;
		})	
	}
	

	
})